import request, { $request }/*, { $http as http }*/ from '@/utils/request';
import { formatParams } from '@/utils'
import api from '@/api'

/**
 * 部门信息
 */
export const getOne = async (params) => {
  return request(api.group_get, {
    params,
  });
}

/**
 * 部门列表
 */
export const getNodes = async (params) => {
  return request(api.group_nodes, {
    params,
  });
}

/**
 * 删除部门
 */
export const deleteNode = async (data) => {
    return request.post(api.group_remove, {
        data,
    });
}

/**
 * 验证部门名称
 */
export const check = async (params) => {
    // return http.post(api.group_name_valid, {
    //     data,
    //     type: true,
    //     requestType: 'form'
    // });
    return $request(api.group_name_valid, {
      params,
    })
}

/**
 * 部门节点查询
 */
export const search = async (params) => {
    return $request(api.group_search, {
      params,
    })
};

/**
 * 部门绑定的角色列表
 */
export const getRoleList = async (data) => {
  const params = formatParams(data);
  return request(api.group_role_list, {
    params,
  });
}

/**
 * 删除部门绑定的角色
 */
export const deleteRoles = async (data) => {
    return request.post(api.group_role_remove, {
        data,
    });
}


/**
 * 部门绑定的用户列表
 */
export const getUserList = async (data) => {
  const params = formatParams(data);
  return request(api.group_user_list, {
    params,
  });
}

/**
 * 删除部门绑定的用户
 */
export const deleteUsers = async (data) => {
    return request.post(api.group_user_remove, {
        data,
    });
}